package com.supreme.commonmongo.mapstructMapper;

import com.supreme.common.entityRocketmq.MQLogger;
import com.supreme.commonmongo.entity.MngLogger;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.time.LocalDateTime;

@Mapper(componentModel = "spring", imports = {LocalDateTime.class})
public interface LoggerObjectMapper {

//    LoggerObjectMapper INSTANCE = Mappers.getMapper(LoggerObjectMapper.class);

    /**
     * MQLogger映射到MngLogger
     * Mapping(target = "id", ignore = true) 忽略[id]字段
     * Mapping(target = "createTime", expression = "java(LocalDateTime.now())") java表达式填充[createTime]字段
     * @param logger MQLogger
     * @return MngLogger
     */
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", expression = "java(LocalDateTime.now())")
    MngLogger mappingToMongoLogger(MQLogger logger);
}
